package com.iterator.service.web.systemManager;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iterator.bean.web.wy.log.Log;
import com.iterator.bean.web.wy.log.LogExample;
import com.iterator.bean.web.wy.log.LogVO;
import com.iterator.mapper.web.systemManager.LogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: Silence_W
 * @date: 2021-01-10 16:43
 **/
@Service
public class LogServiceImpl implements LogService {
    @Autowired
    LogMapper logMapper;


    //管理员操作日志显示
    @Override
    public LogVO queryLog(Integer page, Integer limit, String name, String sort, String order) {
        PageHelper.startPage(page,limit);
        LogExample logExample = new LogExample();
        logExample.setOrderByClause(sort+" "+order);
        LogExample.Criteria criteria = logExample.createCriteria();
        if (name!=null){
            criteria.andAdminLike("%"+name+"%");
        }
        List<Log> logs = logMapper.selectByExample(logExample);
        PageInfo<Log> logPageInfo = new PageInfo<>(logs);
        int total = (int) logPageInfo.getTotal();

        return new LogVO(total,logs);
    }
}
